package com.example.teamtribe.main;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.example.teamtribe.main.chat.ChatFragment;
import com.example.teamtribe.main.club.ClubFragment;
import com.example.teamtribe.main.mine.MineFragment;
import com.example.teamtribe.main.seek.SeekFragment;

public class HomeAdapter extends FragmentPagerAdapter {

    private ClubFragment fragClub;
    private SeekFragment fragSeek;
    private ChatFragment fragChat;
    private MineFragment fragMine;

    public HomeAdapter(FragmentManager fm) {
        super(fm);
        fragClub = new ClubFragment();
        fragSeek = new SeekFragment();
        fragChat = new ChatFragment();
        fragMine = new MineFragment();
    }

    @Override
    public Fragment getItem(int position) {
        switch (position) {
            case 0:
                return fragClub;
            case 1:
                return fragSeek;
            case 2:
                return fragChat;
            case 3:
                return fragMine;
            default:
                return fragClub;
        }
    }

    @Override
    public int getCount() {
        return 4;
    }

    @Override
    public int getItemPosition(Object object) {
        if (object instanceof ClubFragment) {
            return 0;
        } else if (object instanceof SeekFragment) {
            return 1;
        } else if (object instanceof ChatFragment) {
            return 2;
        } else {
            return 3;
        }
    }
}
